import glob from 'glob'
import chalk from 'chalk'
import fs from 'fs'
//'../smart-file-ui/node_modules/elead-components-v3/dist'
export const copyDistToProject = (proPath) => {
	let curDistPath = './dist'
	let smartFileUiDistPath = proPath
	let distDirs = glob.sync(curDistPath)
	let smartFileUiDistDirs = glob.sync(smartFileUiDistPath)
	if (distDirs.length > 0) {
		if (smartFileUiDistDirs.length > 0) {
			//递归删除
			fs.rmSync(smartFileUiDistDirs[0], {recursive: true})
		}
		//创建文件夹
		fs.mkdirSync(smartFileUiDistPath, {recursive: true})
		//复制
		fs.cpSync(curDistPath, smartFileUiDistPath, {recursive: true})
		console.log(chalk.green('完成复制!'))
	} else {
		console.log(chalk.red('找不到对应目录 , 任务终止 , 如果没有安装elead-components-v3, 请先安装到主工程'))
	}
}
//smart-file-ui
copyDistToProject('../smart-file-ui/node_modules/elead-components-v3/dist')
copyDistToProject('../smart-portal-ui/node_modules/elead-components-v3/dist')
copyDistToProject('../smart-timesheet-ui/node_modules/elead-components-v3/dist')

